package com.kfm.pm;

public class Demo {

    public static void test01(String username, String password) throws MyException {
        System.out.println("test01方法");
        if (username == null || username.isEmpty() || password == null || password.isEmpty()) {
            throw new MyException("张艺健和李国威打架");
        }
    }

    public static void test02(String username, String password) throws Exception {
        System.out.println("test02方法");
        try {
            test01(username, password);
        } catch (MyException e) {
            throw new Exception("张艺健告诉何老师，我打架了", e);
        }
    }

    public static void login(String username, String password) throws Exception {
        System.out.println("login方法");
        try {
            test02(username, password);
        } catch (Exception e) {

//            throw new Exception("何老师告诉林老师有人打架了", e);
            Exception e1 = new Exception("何老师告诉林老师有人打架了");
            e1.initCause(e);
            throw e1;
        }
    }

    public static void main(String[] args) {
        try {
            login("", "123");
        } catch (Exception e) {
            System.out.println(e.getMessage());
            Throwable zyj = e.getCause();
            System.out.println(zyj.getMessage());
            Throwable lgw = zyj.getCause();
            System.out.println(lgw.getMessage());
        }
    }
}
